//
//  MYShopSalesOrderRemarkCell.swift
//  MuYing
//
//  Created by tbb on 2019/7/30.
//  Copyright © 2019 TBB. All rights reserved.
//

import UIKit

class MYShopSalesOrderRemarkCell: MYShopSalesOrderBaseTextCell,QMUITextFieldDelegate {
     
    @objc var remarkTextBlock:((_ msg:String)->(Void))?
    
    @objc lazy var remarkTextField: QMUITextField = {
        let remarkTextField = QMUITextField();
        remarkTextField.borderStyle = .none;
        remarkTextField.placeholderColor = UIColorFromHex(rgbValue: 0xC3C3C3);
        remarkTextField.placeholder = kYQLSSwift("选填: 填写内容已和卖家协商的内容");
    
        remarkTextField.font = UIFont.systemFont(ofSize: 14, weight: .medium)
        remarkTextField.textColor = appMainTitleColor;
        remarkTextField.delegate = self;
        return remarkTextField;
    }()
    
    lazy var lineView: UIView = {
        let lineView = UIView();
        lineView.backgroundColor = UIColorFromHex(rgbValue: 0xFAFAFA);
        return lineView;
    }()
    
    override func layoutSubviews() {
        super.layoutSubviews();
        self.contentView.addSubview(self.remarkTextField);
        self.remarkTextField.mas_makeConstraints { (make) in
            make?.left.mas_equalTo()(self.textLb.mas_right)?.mas_equalTo()(12);
            make?.centerY.mas_equalTo()(0);
            make?.height.mas_equalTo()(20);
            make?.right.mas_lessThanOrEqualTo()(-12);
        }
        
        self.contentView.addSubview(self.lineView);
        self.lineView.mas_makeConstraints { (make) in
            make?.top.mas_equalTo()(0);
            make?.left.mas_equalTo()(0);
            make?.right.mas_equalTo()(0);
            make?.height.mas_equalTo()(1);
        };
    }

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier);

    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}

extension MYShopSalesOrderRemarkCell {
    func textFieldDidEndEditing(_ textField: UITextField) {
        if let remarkTextBlock = self.remarkTextBlock {
            remarkTextBlock(textField.text ?? "");
        }
    }
}
